//
// Copyright (C) 2011 - 2013  Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1
//#include "stdafx.h"
#include "BivariateCumulativeNormalDistributionDr78.h"
using namespace Cephei::QL::Math::Distributions;
#undef HANDLE
#undef ABSTRACT
#undef STRUCT
Cephei::QL::Math::Distributions::CBivariateCumulativeNormalDistributionDr78::CBivariateCumulativeNormalDistributionDr78 (Double rho) 
{
	_pSpinlock = new boost::detail::spinlock ();
    try
    {
#ifdef HANDLE
        _phBivariateCumulativeNormalDistributionDr78 = NULL;
#endif
        QuantLib::Real _rho = (QuantLib::Real)ValueHelper::Convert (rho); //d
        _ppBivariateCumulativeNormalDistributionDr78 = new boost::shared_ptr<QuantLib::BivariateCumulativeNormalDistributionDr78> (new QuantLib::BivariateCumulativeNormalDistributionDr78 ( _rho ));
        
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Math::Distributions::CBivariateCumulativeNormalDistributionDr78::CBivariateCumulativeNormalDistributionDr78 (boost::shared_ptr<QuantLib::BivariateCumulativeNormalDistributionDr78>& childNative, Object^ owner) 
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phBivariateCumulativeNormalDistributionDr78 = NULL;
#endif
	_ppBivariateCumulativeNormalDistributionDr78 = &childNative;
    
}
Cephei::QL::Math::Distributions::CBivariateCumulativeNormalDistributionDr78::CBivariateCumulativeNormalDistributionDr78 (QuantLib::BivariateCumulativeNormalDistributionDr78& childNative, Object^ owner) 
{
#ifdef HANDLE
	_phBivariateCumulativeNormalDistributionDr78 = NULL;
#endif
	_ppBivariateCumulativeNormalDistributionDr78 = new boost::shared_ptr<QuantLib::BivariateCumulativeNormalDistributionDr78> (&childNative);
    
    _BivariateCumulativeNormalDistributionDr78Owner = owner;
    
}

Cephei::QL::Math::Distributions::CBivariateCumulativeNormalDistributionDr78::CBivariateCumulativeNormalDistributionDr78 (CBivariateCumulativeNormalDistributionDr78^ copy) 
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phBivariateCumulativeNormalDistributionDr78 = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppBivariateCumulativeNormalDistributionDr78 = new boost::shared_ptr<QuantLib::BivariateCumulativeNormalDistributionDr78> (copy->GetShared());
        
    }
}
Cephei::QL::Math::Distributions::CBivariateCumulativeNormalDistributionDr78::CBivariateCumulativeNormalDistributionDr78 (PLATFORM::Type^ t) 
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phBivariateCumulativeNormalDistributionDr78 = NULL;
#endif
	if (!t->IsSubclassOf(CBivariateCumulativeNormalDistributionDr78::typeid))
		throw REFNEW Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Math::Distributions::CBivariateCumulativeNormalDistributionDr78::CBivariateCumulativeNormalDistributionDr78 (QuantLib::Handle<QuantLib::BivariateCumulativeNormalDistributionDr78>& childNative, Object^ owner)  
{
	_pSpinlock = new boost::detail::spinlock ();
	_phBivariateCumulativeNormalDistributionDr78 = &childNative;
	_ppBivariateCumulativeNormalDistributionDr78 = &static_cast<boost::shared_ptr<QuantLib::BivariateCumulativeNormalDistributionDr78>>(childNative.currentLink());
    
    _BivariateCumulativeNormalDistributionDr78Owner = owner;
}
Cephei::QL::Math::Distributions::CBivariateCumulativeNormalDistributionDr78::CBivariateCumulativeNormalDistributionDr78 (QuantLib::Handle<QuantLib::BivariateCumulativeNormalDistributionDr78> childNative)  
{
	_pSpinlock = new boost::detail::spinlock ();
	_phBivariateCumulativeNormalDistributionDr78 = &childNative;
	_ppBivariateCumulativeNormalDistributionDr78 = &static_cast<boost::shared_ptr<QuantLib::BivariateCumulativeNormalDistributionDr78>>(childNative.currentLink());
    
}
#endif
#ifdef STRUCT
Cephei::QL::Math::Distributions::CBivariateCumulativeNormalDistributionDr78::CBivariateCumulativeNormalDistributionDr78 (QuantLib::BivariateCumulativeNormalDistributionDr78 childNative)  
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phBivariateCumulativeNormalDistributionDr78 = NULL;
#endif
	_ppBivariateCumulativeNormalDistributionDr78 = new boost::shared_ptr<QuantLib::BivariateCumulativeNormalDistributionDr78> (new QuantLib::BivariateCumulativeNormalDistributionDr78 (childNative));
    
}
#endif

Cephei::QL::Math::Distributions::CBivariateCumulativeNormalDistributionDr78::~CBivariateCumulativeNormalDistributionDr78 ()
{
	if (_pSpinlock != NULL)
    {
        delete _pSpinlock;
        _pSpinlock = NULL;
    }
    if (_ppBivariateCumulativeNormalDistributionDr78 != NULL)
    {
	    delete _ppBivariateCumulativeNormalDistributionDr78;
        _ppBivariateCumulativeNormalDistributionDr78 = NULL;
    }
}
Cephei::QL::Math::Distributions::CBivariateCumulativeNormalDistributionDr78::!CBivariateCumulativeNormalDistributionDr78 ()
{
	if (_pSpinlock != NULL)
    {
        delete _pSpinlock;
    }
    if (_ppBivariateCumulativeNormalDistributionDr78 != NULL)
    {
	    delete _ppBivariateCumulativeNormalDistributionDr78;
    }
}
QuantLib::BivariateCumulativeNormalDistributionDr78& Cephei::QL::Math::Distributions::CBivariateCumulativeNormalDistributionDr78::GetReference ()
{
    if (_ppBivariateCumulativeNormalDistributionDr78 == NULL) throw REFNEW NativeNullException ();
	return **_ppBivariateCumulativeNormalDistributionDr78;
}
boost::shared_ptr<QuantLib::BivariateCumulativeNormalDistributionDr78>& Cephei::QL::Math::Distributions::CBivariateCumulativeNormalDistributionDr78::GetShared ()
{
    if (_ppBivariateCumulativeNormalDistributionDr78 == NULL) throw REFNEW NativeNullException ();
	return *_ppBivariateCumulativeNormalDistributionDr78;
}
QuantLib::BivariateCumulativeNormalDistributionDr78* Cephei::QL::Math::Distributions::CBivariateCumulativeNormalDistributionDr78::GetPointer ()
{
    if (_ppBivariateCumulativeNormalDistributionDr78 == NULL) throw REFNEW NativeNullException ();
	return &**_ppBivariateCumulativeNormalDistributionDr78;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::BivariateCumulativeNormalDistributionDr78>& Cephei::QL::Math::Distributions::CBivariateCumulativeNormalDistributionDr78::GetHandle ()
{
	if (_phBivariateCumulativeNormalDistributionDr78 == NULL)
	{
		_phBivariateCumulativeNormalDistributionDr78 = new Handle<QuantLib::BivariateCumulativeNormalDistributionDr78> (*_ppBivariateCumulativeNormalDistributionDr78);
	}
	return *_phBivariateCumulativeNormalDistributionDr78;
}
#endif
bool Cephei::QL::Math::Distributions::CBivariateCumulativeNormalDistributionDr78::HasNative () 
{
	return (_ppBivariateCumulativeNormalDistributionDr78 != NULL);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

Cephei::QL::Math::Distributions::IBivariateCumulativeNormalDistributionDr78^ Cephei::QL::Math::Distributions::CBivariateCumulativeNormalDistributionDr78_Factory::Create (Double rho)
{
    return REFNEW CBivariateCumulativeNormalDistributionDr78 ( rho);
}
